body {
    font-family: Arial, sans-serif;
    display: flex;
    /* flex-direction: column; */ /* Changed for side-by-side layout */
    align-items: flex-start; /* Align items to the top */
    justify-content: center; /* Center content horizontally */
    min-height: 100vh;
    margin: 0;
    background-color: #f0f2f5; /* Slightly different background */
    padding: 20px;
    box-sizing: border-box;
}

.main-container {
    display: flex;
    width: 100%;
    max-width: 1200px; /* Max width for the whole layout */
    gap: 20px; /* Space between flashcard area and AI area */
}

.flashcard-area {
    flex: 1; /* Takes up available space */
    display: flex;
    flex-direction: column;
    align-items: center;
}

#wrongQuestionsListContainer { /* Added styles for wrong questions list */
    width: 100%;
    max-width: 450px; /* Match card container width */
    margin-bottom: 20px;
    background-color: #fdfdfd;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 1px 6px rgba(0,0,0,0.07);
    border: 1px solid #e7e7e7;
}

#wrongQuestionsListContainer h4 {
    margin-top: 0;
    margin-bottom: 10px;
    color: #c0392b; /* A reddish color for "wrong" items */
    font-size: 1.1em;
    text-align: center;
}

#wrongQuestionsList {
    list-style-type: none;
    padding: 0;
    max-height: 150px; /* Limit height and make scrollable */
    overflow-y: auto;
    font-size: 0.9em;
}

#wrongQuestionsList li {
    padding: 8px 5px;
    border-bottom: 1px dashed #eee;
    cursor: pointer;
    transition: background-color 0.2s ease;
    color: #34495e;
}
#wrongQuestionsList li:last-child {
    border-bottom: none;
}
#wrongQuestionsList li:hover {
    background-color: #ecf0f1;
}
#wrongQuestionsList .no-wrong-questions {
    font-style: italic;
    color: #7f8c8d;
    text-align: center;
    padding: 10px 0;
    cursor: default;
}
#wrongQuestionsList .no-wrong-questions:hover {
    background-color: transparent;
}

.container { /* Renamed from .flashcard-area's previous .container */
    text-align: center;
    background-color: #ffffff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.card-container {
    perspective: 1500px;
    width: 450px;
    height: 300px;
    margin-bottom: 30px;
}

.card {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.8s cubic-bezier(0.25, 0.8, 0.25, 1);
    cursor: pointer;
    border-radius: 15px;
}

.card.flipped {
    transform: rotateY(180deg);
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 25px;
    box-sizing: border-box;
    border-radius: 15px;
    overflow-y: auto;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
    text-align: center;
}

.send-to-ai-button {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    padding: 5px 10px;
    font-size: 0.8em;
    background-color: #6c757d;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    z-index: 10; /* Ensure button is clickable */
}
.send-to-ai-button:hover {
    background-color: #5a6268;
}

.card-front {
    color: #000000;
    font-size: 1.8em;
    font-weight: bold;
}

.card-back {
    color: #000000;
    transform: rotateY(180deg);
    font-size: 1.1em;
    line-height: 1.7;
}

.controls button, .controls input[type="file"] {
    padding: 10px 15px;
    margin: 5px;
    font-size: 1em;
    cursor: pointer;
    border: none;
    border-radius: 5px;
    background-color: #007BFF;
    color: white;
    transition: background-color 0.3s ease;
}

.controls button:hover, .controls input[type="file"]:hover {
    background-color: #0056b3;
}

#fileNameDisplay {
    margin-top: 10px;
    font-style: italic;
    color: #555;
}

#progressDisplay {
    margin-top: 10px;
    font-size: 0.9em;
    color: #333;
}

/* AI Chat Area Styles */
.ai-chat-area {
    flex: 0 0 350px; /* Fixed width for AI chat area */
    background-color: #ffffff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    height: calc(100vh - 40px); /* Adjust height to fit viewport */
    max-height: 700px; /* Max height */
}

.ai-chat-area h2 {
    text-align: center;
    margin-top: 0;
    color: #333;
}

#apiKeyInputContainer {
    margin-bottom: 15px;
}

#apiKeyInputContainer input {
    width: calc(100% - 22px);
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

#apiKeyInputContainer button {
     padding: 10px 15px;
     margin-left: 5px;
     font-size: 0.9em;
     cursor: pointer;
     border: none;
     border-radius: 5px;
     background-color: #28a745;
     color: white;
}

#chatHistory {
    flex-grow: 1;
    overflow-y: auto;
    border: 1px solid #eee;
    padding: 10px;
    margin-bottom: 10px;
    border-radius: 4px;
    background-color: #f9f9f9;
}

.chat-message {
    margin-bottom: 10px;
    padding: 8px;
    border-radius: 4px;
    line-height: 1.4;
}

.user-message {
    background-color: #d1e7fd;
    text-align: right;
    margin-left: auto; /* Push to right */
    max-width: 80%;
}

.ai-message {
    background-color: #e2e3e5;
    text-align: left;
    margin-right: auto; /* Push to left */
    max-width: 80%;
}

#chatInputContainer {
    display: flex;
}

#chatInput {
    flex-grow: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px 0 0 4px;
}

#sendChatButton {
    padding: 10px 15px;
    border: none;
    background-color: #007BFF;
    color: white;
    cursor: pointer;
    border-radius: 0 4px 4px 0;
}
#sendChatButton:hover {
    background-color: #0056b3;
}

/* Styles for Search Results */
.search-result-item {
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.9em;
    color: #333;
}
.search-result-item:last-child {
    border-bottom: none;
}
.search-result-item:hover {
    background-color: #e9ecef;
}
.search-no-results {
    padding: 10px 12px;
    font-style: italic;
    color: #777;
    font-size: 0.9em;
}

/* Styles for AI Preset Action Buttons */
.ai-preset-button {
    padding: 8px 12px;
    font-size: 0.9em;
    cursor: pointer;
    border: none;
    border-radius: 4px;
    background-color: #5bc0de; /* Bootstrap Info color */
    color: white;
    transition: background-color 0.3s ease;
}

.ai-preset-button:hover {
    background-color: #31b0d5;
}
